package com.itwn.realm;

import com.itwn.bean.Permissions;
import com.itwn.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @ClassName: MyFilterMap
 * @Author: 流光亦断
 * @Date: 2021/8/20 11:58
 * @Version: 1.0     // 版本
 */
public class MyFilterMap {
    @Autowired
    private UserService userService;
    public Map<String,String> getMap(){
        Map<String, String> map = new LinkedHashMap<>();
        map.put("/index1.jsp","anon");
        map.put("/login.jsp","anon");
        map.put("/register.jsp","anon");
        map.put("/hello","anon");
        map.put("/userlogin","anon");
        map.put("/reg","anon");
        map.put("/logout","logout");
        map.put("/css/**","anon");
        map.put("/fonts/**","anon");
        map.put("/images/**","anon");
        map.put("/img/**","anon");
        map.put("/js/**","anon");
        map.put("/**","authc");
        List<Permissions>list=userService.getPermission();
        for (Permissions p : list) {
            map.put(p.getPermissionsName(),"roles["+p.getRoles().getRolesName()+"]");
        }
        System.out.println(map);
        return map;

    }
}
